require("TSLib")
logger = require("logger")

local M = {}




function knapsack_grid(row,column)
	local knapsack_column = {700, 780, 860, 940, 1020}
	local knapsack_row = {170, 240, 320, 400}
	return knapsack_column[column], knapsack_row[row]
end

function find_stock_of_knapsack(row, column)
	x,y = knapsack_grid(row,column)
	
	logger.debug(row..","..column)
	logger.debug(x..","..y)
	
	if (isColor( x, y, 0xeaceab, 98)) then
		--logger.debug("the knapsack is nil.")
		return false, -1, -1
	end
	--logger.debug("the knapsack not nil.")
	return true, x, y
end

function find_goods_in_stock(...)
	for row = 1, 4, 1 do
		for column = 1, 5, 1 do
			is_find, x, y = find_stock_of_knapsack(row,column)
			if is_find then
				return x,y
			end
		end
	end
	return -1, -1
end

function main(...)
	init(1)
	x, y = find_goods_in_stock()
	--x, y = find_stock_of_knapsack(1,1)
	mSleep(1000)
	--logger.debug(x)
	mSleep(1000)
end


--main()
return M;